package com.ruoyi.system.service.estate.emergency.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.mapper.estate.emergency.EmergencySuppliesMapper;
import com.ruoyi.system.domain.estate.emergency.EmergencySupplies;
import com.ruoyi.system.service.estate.emergency.IEmergencySuppliesService;

/**
 * 应急物资Service业务层处理
 */
@Service
public class EmergencySuppliesServiceImpl implements IEmergencySuppliesService {
    @Autowired
    private EmergencySuppliesMapper emergencySuppliesMapper;

    /**
     * 查询应急物资列表
     * 
     * @param emergencySupplies 应急物资信息
     * @return 应急物资集合
     */
    @Override
    public List<EmergencySupplies> selectEmergencySuppliesList(EmergencySupplies emergencySupplies) {
        return emergencySuppliesMapper.selectEmergencySuppliesList(emergencySupplies);
    }

    /**
     * 查询应急物资详细信息
     * 
     * @param suppliesId 应急物资ID
     * @return 应急物资信息
     */
    @Override
    public EmergencySupplies selectEmergencySuppliesById(Long suppliesId) {
        return emergencySuppliesMapper.selectEmergencySuppliesById(suppliesId);
    }

    /**
     * 新增应急物资
     * 
     * @param emergencySupplies 应急物资信息
     * @return 结果
     */
    @Override
    public int insertEmergencySupplies(EmergencySupplies emergencySupplies) {
        emergencySupplies.setCreateTime(new Date());
        emergencySupplies.setCreateBy(SecurityUtils.getUsername());
        emergencySupplies.setDelFlag("0");
        if (emergencySupplies.getStatus() == null) {
            emergencySupplies.setStatus("0");
        }
        return emergencySuppliesMapper.insertEmergencySupplies(emergencySupplies);
    }

    /**
     * 修改应急物资
     * 
     * @param emergencySupplies 应急物资信息
     * @return 结果
     */
    @Override
    public int updateEmergencySupplies(EmergencySupplies emergencySupplies) {
        emergencySupplies.setUpdateTime(new Date());
        emergencySupplies.setUpdateBy(SecurityUtils.getUsername());
        return emergencySuppliesMapper.updateEmergencySupplies(emergencySupplies);
    }

    /**
     * 批量删除应急物资
     * 
     * @param suppliesIds 需要删除的应急物资ID
     * @return 结果
     */
    @Override
    public int deleteEmergencySuppliesByIds(Long[] suppliesIds) {
        return emergencySuppliesMapper.deleteEmergencySuppliesByIds(suppliesIds);
    }

    /**
     * 删除应急物资信息
     * 
     * @param suppliesId 应急物资ID
     * @return 结果
     */
    @Override
    public int deleteEmergencySuppliesById(Long suppliesId) {
        return emergencySuppliesMapper.deleteEmergencySuppliesById(suppliesId);
    }
    
    /**
     * 获取应急物资统计数据
     * 
     * @return 统计数据
     */
    @Override
    public Map<String, Object> selectEmergencySuppliesStatistics() {
        return emergencySuppliesMapper.selectEmergencySuppliesStatistics();
    }
    
    /**
     * 获取应急物资类型统计
     * 
     * @return 类型统计数据
     */
    @Override
    public List<Map<String, Object>> selectEmergencySuppliesTypeStatistics() {
        return emergencySuppliesMapper.selectEmergencySuppliesTypeStatistics();
    }
} 